feat: #106 Improve signIn error handling#107
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
WalkthroughThe sign-in form's email validation was updated to require a valid email format instead of just a non-empty string. Additionally, the authentication logic now translates backend errors into clearer, user-friendly messages using a new internal helper function, improving error feedback during sign-in attempts. Changes
Poem
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
npm error Exit handler never called! ✨ Finishing Touches
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (2)
src/pages/AuthPage/components/SignInForm/SignInForm.schema.ts (1)
4-4: Update error message to match email format validation.The validation correctly requires a proper email format, but the error message "Please enter your email." is misleading for format validation failures. Consider updating it to indicate the format requirement.
- email: z.string().email('Please enter your email.').transform((val) => val.trim().toLowerCase()), + email: z.string().email('Please enter a valid email address.').transform((val) => val.trim().toLowerCase()),src/services/auth/useSignIn.ts (1)
17-28: Consider improving error type safety and robustness.The error mapping function is a good approach for user-friendly messaging. However, consider these improvements:
- Type safety: Instead of
any, consider defining a proper error type or usingunknownwith type guards.- Robustness: The string inclusion check could be more specific to avoid false positives.
-// eslint-disable-next-line @typescript-eslint/no-explicit-any -function mapConvexAuthError(error: any): string { +function mapConvexAuthError(error: unknown): string { + if (typeof error !== 'object' || error === null) { + return 'An unexpected error occurred. Please try again.'; + } + + const errorObj = error as { message?: string }; - if (!error?.message) { + if (!errorObj.message || typeof errorObj.message !== 'string') { return 'An unexpected error occurred. Please try again.'; } - if (error.message.includes('InvalidAccountId')) { + if (errorObj.message.includes('InvalidAccountId')) { return 'Your email or password is incorrect.'; } return 'Sign-in failed. Please check your details and try again.'; }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
src/pages/AuthPage/components/SignInForm/SignInForm.schema.ts(1 hunks)src/services/auth/useSignIn.ts(2 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
src/services/auth/useSignIn.ts (1)
src/components/ToastProvider/ToastProvider.store.ts (1)
toast(29-50)
🔇 Additional comments (1)
src/services/auth/useSignIn.ts (1)
63-65: LGTM! Error handling integration looks good.The integration of the error mapping function with the toast notification provides a better user experience by showing meaningful error messages instead of raw backend errors.
* Update update-project-status.yml * Update updateProjectStatus.js * fix: Toast text does not wrap (#87) * fix: #86 Sanitize sign in/sign up inputs (#91) * feat: #32 Auto generate avatars & refactor users (#90) * feat: Improve <TournamentDetailPage/> default tab * feat: Improve <TournamentCard/> styling * Update mockData.ts * feat: Improve <AccordionItem/> disabled state (#97) #94 * feat: Hide completed pairings from match check-in (#96) #95 * bug: Preserve <TournamentPairingsGrid/> internal state (#98) #93 * feat: #101 Add player count to roster (#103) * feat: Show full player names when tournaments require it * feat: Add activePlayerCount to deep tournaments * feat: Sort tournament competitors by name * task: #100 Clean-up .card mixin (#102) * feat: #99 Improve tournament competitor edit dialog (#104) * feat: #106 Improve signIn error handling (#107) * Update convex/_model/tournamentCompetitors/queries/getTournamentCompetitorsByTournament.ts * Update convex/_model/users/_helpers/checkUserTournamentForcedName.ts * feat: Hide players with 0 matches from rankings
* Update update-project-status.yml * Update updateProjectStatus.js * fix: Toast text does not wrap (#87) * fix: #86 Sanitize sign in/sign up inputs (#91) * feat: #32 Auto generate avatars & refactor users (#90) * feat: Improve <TournamentDetailPage/> default tab * feat: Improve <TournamentCard/> styling * Update mockData.ts * feat: #94 Improve <AccordionItem/> disabled state (#97) * feat: #95 Hide completed pairings from match check-in (#96) * bug: #93 Preserve <TournamentPairingsGrid/> internal state (#98) * feat: #101 Add player count to roster (#103) * feat: Show full player names when tournaments require it * feat: Add activePlayerCount to deep tournaments * feat: Sort tournament competitors by name * task: #100 Clean-up .card mixin (#102) * feat: #99 Improve tournament competitor edit dialog (#104) * feat: #106 Improve signIn error handling (#107) * Update convex/_model/tournamentCompetitors/queries/getTournamentCompetitorsByTournament.ts * Update convex/_model/users/_helpers/checkUserTournamentForcedName.ts * feat: Hide players with 0 matches from rankings * feat: #112 Add more mercenary team options (#113) * feat: #110 Add manual table assignments (#111) * fix: Ensure round 0 rankings can be included * Refactor tournament actions (#114) * refactor: Improve tournament actions * chore: Clean-up Convex errors * fix: Do not try to clean up current round timer on tournament end * fix: Don't allow players to be removed from tournament * chore: Update test tournament banner image * Update TournamentCard.tsx * fix: Ensure round 0 rankings can be included * fix: Fix end tournament round context menu behavior * chore: Improve mock match result creation * feat: Allow matchResult.playedAt to be date string or number * feat: #115 Hide match result battle plans (#116) * feat: Set page title based on <PageWrapper/> title prop * fix: Use <IdentityBadge/> to fix player name spacing on match results * fix: Correctly include match results relevant to a tournament
* Update update-project-status.yml * Update updateProjectStatus.js * fix: Toast text does not wrap (#87) * fix: Sanitize sign in/sign up inputs (#91) #86 * feat: #32 Auto generate avatars & refactor users (#90) * feat: Improve <TournamentDetailPage/> default tab * feat: Improve <TournamentCard/> styling * Update mockData.ts * feat: Improve <AccordionItem/> disabled state (#97) #94 * feat: Hide completed pairings from match check-in (#96) #95 * bug: Preserve <TournamentPairingsGrid/> internal state (#98) #93 * feat: #101 Add player count to roster (#103) * feat: Show full player names when tournaments require it * feat: Add activePlayerCount to deep tournaments * feat: Sort tournament competitors by name * task: Clean-up .card mixin (#102) #100 * feat: #99 Improve tournament competitor edit dialog (#104) * feat: #106 Improve signIn error handling (#107) * Update convex/_model/tournamentCompetitors/queries/getTournamentCompetitorsByTournament.ts Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * Update convex/_model/users/_helpers/checkUserTournamentForcedName.ts Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * feat: Hide players with 0 matches from rankings * feat: #112 Add more mercenary team options (#113) * feat: #110 Add manual table assignments (#111) * fix: Ensure round 0 rankings can be included * Refactor tournament actions (#114) * refactor: Improve tournament actions * chore: Clean-up Convex errors * fix: Do not try to clean up current round timer on tournament end * fix: Don't allow players to be removed from tournament * chore: Update test tournament banner image * Update TournamentCard.tsx * fix: Ensure round 0 rankings can be included * fix: Fix end tournament round context menu behavior * chore: Improve mock match result creation * feat: Allow matchResult.playedAt to be date string or number * feat: #115 Hide match result battle plans (#116) * feat: Set page title based on <PageWrapper/> title prop * fix: Use <IdentityBadge/> to fix player name spacing on match results * fix: Correctly include match results relevant to a tournament * feat: #57 Implement basic dashboard (#119) * fix: Remove double border on dashboard sections * fix: Add key to dashboard tournaments * feat: Improve <TournamentPairingRow/> styling * fix: Remove extraneous error message * fix: Improve <Form/> isDirty calculation * fix: Render all competitors in <TournamentCompetitorForm/> * fix: Also show empty state if rankings are empty --------- Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Summary by CodeRabbit
Bug Fixes
New Features